package com.hgd.security.evp.biz.rest;

import com.hgd.security.evp.biz.biz.EGroupUserBiz;
import com.hgd.security.evp.biz.entity.EvpGroupUser;
import com.hgd.security.evp.common.util.ObjectResultResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("eGroupUser")
@Api(tags = "用户--组管理")
@Log4j
public class EGroupUserController {
    @Autowired
    private EGroupUserBiz eGroupUserBiz;

    @PostMapping("/instance")
    @ApiOperation("添加用户--组记录")
    public ObjectResultResponse<Void> addEGroupUser(
            @RequestParam(value = "groupId") @ApiParam(value = "组ID") Integer groupId,
            @RequestParam(value = "userId") @ApiParam(value = "用户ID") Integer userId
    ) {
        log.info("/eGroupUser/instance==>添加用户--组记录");

        EvpGroupUser eGroupUser=new EvpGroupUser();
        eGroupUser.setGroupId(groupId);
        eGroupUser.setUserId(userId);

        return eGroupUserBiz.addEGroupUser(eGroupUser);
    }

    @DeleteMapping("/instance")
    @ApiOperation("删除用户--组记录")
    public ObjectResultResponse<Void> delEGroupUser(
        @RequestParam(value = "groupId") @ApiParam(value = "组ID") Integer groupId,
        @RequestParam(value = "userId") @ApiParam(value = "用户ID") Integer userId
    ) {
        log.info("/eGroupUser/instance==>删除用户--组记录");

        EvpGroupUser eGroupUser=new EvpGroupUser();
        eGroupUser.setGroupId(groupId);
        eGroupUser.setUserId(userId);

        return eGroupUserBiz.delEGroupUser(eGroupUser);
    }
}